clang-tidy readability-delete-null-pointer

which in turn triggered some loplugin:useuniqueptr

Change-Id: I0c38561fc9b68dac44e8cf58c8aa1f582196cc64
Reviewed-on: https://gerrit.libreoffice.org/38281
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index b70d6c5..fdd0463 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -935,10 +935,6 @@

MenuSaveInData::~MenuSaveInData()
{
    if ( pRootEntry != nullptr )
    {
        delete pRootEntry;
    }
}

SvxEntries*
@@ -946,16 +942,16 @@
{
    if ( pRootEntry == nullptr )
    {
        pRootEntry = new SvxConfigEntry( "MainMenus", OUString(), true);
        pRootEntry.reset( new SvxConfigEntry( "MainMenus", OUString(), true) );

        if ( m_xMenuSettings.is() )
        {
            LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry, false );
            LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry.get(), false );
        }
        else if ( GetDefaultData() != nullptr )
        {
            // If the doc has no config settings use module config settings
            LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry, false );
            LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry.get(), false );
        }
    }

@@ -1226,8 +1222,7 @@

    PersistChanges( GetConfigManager() );

    delete pRootEntry;
    pRootEntry = nullptr;
    pRootEntry.reset();

    try
    {
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index 329b695..0436f15 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -168,7 +168,7 @@
    css::uno::Reference
        < css::container::XIndexAccess > m_xMenuSettings;

    SvxConfigEntry* pRootEntry;
    std::unique_ptr<SvxConfigEntry>      pRootEntry;


    static MenuSaveInData* pDefaultData;    ///< static holder of the default menu data
diff --git a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
index 750d4d8..3f901f6 100644
--- a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
@@ -442,10 +442,6 @@

        SdrExtrudePrimitive3D::~SdrExtrudePrimitive3D()
        {
            if(mpLastRLGViewInformation)
            {
                delete mpLastRLGViewInformation;
            }
        }

        bool SdrExtrudePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
@@ -493,8 +489,7 @@
                    // new one and clear current decompositiopn
                    SdrExtrudePrimitive3D* pThat = const_cast< SdrExtrudePrimitive3D* >(this);
                    pThat->setBuffered3DDecomposition(Primitive3DContainer());
                    delete pThat->mpLastRLGViewInformation;
                    pThat->mpLastRLGViewInformation = new geometry::ViewInformation3D(rViewInformation);
                    pThat->mpLastRLGViewInformation.reset( new geometry::ViewInformation3D(rViewInformation) );
                }
            }

diff --git a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
index 0bffc58..4f38141 100644
--- a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
@@ -302,10 +302,6 @@

        SdrLathePrimitive3D::~SdrLathePrimitive3D()
        {
            if(mpLastRLGViewInformation)
            {
                delete mpLastRLGViewInformation;
            }
        }

        bool SdrLathePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
@@ -355,8 +351,7 @@
                    // new one and clear current decompositiopn
                    SdrLathePrimitive3D* pThat = const_cast< SdrLathePrimitive3D* >(this);
                    pThat->setBuffered3DDecomposition(Primitive3DContainer());
                    delete pThat->mpLastRLGViewInformation;
                    pThat->mpLastRLGViewInformation = new geometry::ViewInformation3D(rViewInformation);
                    pThat->mpLastRLGViewInformation.reset( new geometry::ViewInformation3D(rViewInformation) );
                }
            }

diff --git a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
index 8b95d90..1ce54a3 100644
--- a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
+++ b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
@@ -618,10 +618,7 @@

        ZBufferProcessor3D::~ZBufferProcessor3D()
        {
            if(mpZBufferRasterConverter3D)
            {
                delete mpZBufferRasterConverter3D;
            }
            delete mpZBufferRasterConverter3D;

            if(mpRasterPrimitive3Ds)
            {
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 3eb72a5..f1ea65f 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -1138,8 +1138,7 @@

SvxRTFItemStackType::~SvxRTFItemStackType()
{
    if (m_pChildList)
        delete m_pChildList;
    delete m_pChildList;
    if( pSttNd != pEndNd )
        delete pEndNd;
    delete pSttNd;
diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx
index 5f5b54d..052ab9b 100644
--- a/filter/source/graphicfilter/ios2met/ios2met.cxx
+++ b/filter/source/graphicfilter/ios2met/ios2met.cxx
@@ -487,7 +487,7 @@
    while (pBitmapList!=nullptr) {
        OSBitmap * p=pBitmapList;
        pBitmapList=p->pSucc;
        if (p->pBMP!=nullptr) delete p->pBMP;
        delete p->pBMP;
        delete p;
    }

@@ -500,7 +500,7 @@
    while (pPaletteStack!=nullptr) {
        OSPalette * p=pPaletteStack;
        pPaletteStack=p->pSucc;
        if (p->p0RGB!=nullptr) delete[] p->p0RGB;
        delete[] p->p0RGB;
        delete p;
    }
}
@@ -2504,7 +2504,7 @@
            OSPalette * pP=pPaletteStack;
            if (pP!=nullptr) {
                pPaletteStack=pP->pSucc;
                if (pP->p0RGB!=nullptr) delete[] pP->p0RGB;
                delete[] pP->p0RGB;
                delete pP;
            }
            break;
diff --git a/filter/source/graphicfilter/itiff/ccidecom.cxx b/filter/source/graphicfilter/itiff/ccidecom.cxx
index a30d5eb..c57813e 100644
--- a/filter/source/graphicfilter/itiff/ccidecom.cxx
+++ b/filter/source/graphicfilter/itiff/ccidecom.cxx
@@ -672,8 +672,7 @@
    {
        if ( pLastLine == nullptr || nLastLineSize != ( ( nTargetBits + 7 ) >> 3 ) )
        {
            if ( pLastLine == nullptr )
                delete[] pLastLine;
            delete[] pLastLine;
            nLastLineSize = ( nTargetBits + 7 ) >> 3;
            pLastLine = new sal_uInt8[ nLastLineSize ];
            memset(pLastLine, 0, nLastLineSize);
diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx
index 52e6a78..3f212b4 100644
--- a/hwpfilter/source/htags.cxx
+++ b/hwpfilter/source/htags.cxx
@@ -57,8 +57,7 @@
#endif
EmPicture::~EmPicture()
{
    if (data)
        delete[]data;
    delete[] data;
};

bool EmPicture::Read(HWPFile & hwpf)
diff --git a/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx
index 42bfd73..eea2f2f 100644
--- a/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx
+++ b/include/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx
@@ -24,6 +24,7 @@

#include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <memory>


namespace drawinglayer
@@ -55,7 +56,7 @@
            double                                      mfBackScale;

            /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition
            geometry::ViewInformation3D*                mpLastRLGViewInformation;
            std::unique_ptr<geometry::ViewInformation3D> mpLastRLGViewInformation;

            bool                                        mbSmoothNormals : 1; // Plane self
            bool                                        mbSmoothLids : 1; // Front/back
diff --git a/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx b/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx
index a26aea5..da713c1 100644
--- a/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx
+++ b/include/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx
@@ -24,6 +24,7 @@

#include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <memory>


namespace drawinglayer
@@ -57,7 +58,7 @@
            double                                      mfRotation;

            /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition
            geometry::ViewInformation3D*                mpLastRLGViewInformation;
            std::unique_ptr<geometry::ViewInformation3D> mpLastRLGViewInformation;

            bool                                        mbSmoothNormals : 1; // Plane self
            bool                                        mbSmoothLids : 1; // Front/back
diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx
index 8fe4f1d..a5e939e 100644
--- a/include/vcl/metaact.hxx
+++ b/include/vcl/metaact.hxx
@@ -1433,7 +1433,8 @@
    OString             maComment;
    sal_Int32           mnValue;
    sal_uInt32          mnDataSize;
    sal_uInt8*          mpData;
    std::unique_ptr<sal_uInt8[]>
                        mpData;

    SAL_DLLPRIVATE void ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize );

@@ -1456,7 +1457,7 @@
    const OString&      GetComment() const { return maComment; }
    sal_Int32           GetValue() const { return mnValue; }
    sal_uInt32          GetDataSize() const { return mnDataSize; }
    const sal_uInt8*    GetData() const { return mpData; }
    const sal_uInt8*    GetData() const { return mpData.get(); }
};

class VCL_DLLPUBLIC MetaLayoutModeAction : public MetaAction
diff --git a/io/source/acceptor/acceptor.cxx b/io/source/acceptor/acceptor.cxx
index cb5deba..7dc047a1 100644
--- a/io/source/acceptor/acceptor.cxx
+++ b/io/source/acceptor/acceptor.cxx
@@ -87,14 +87,8 @@

    OAcceptor::~OAcceptor()
    {
        if( m_pPipe )
        {
            delete m_pPipe;
        }
        if( m_pSocket )
        {
            delete m_pSocket;
        }
        delete m_pPipe;
        delete m_pSocket;
    }

    struct BeingInAccept
diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx
index 9053ada..cdf1b09 100644
--- a/io/source/stm/omark.cxx
+++ b/io/source/stm/omark.cxx
@@ -410,7 +410,6 @@
{
public:
    OMarkableInputStream(  );
    virtual ~OMarkableInputStream() override;


public: // XInputStream
@@ -452,7 +451,7 @@
    Reference< XInputStream > m_input;
    bool m_bValidStream;

    MemRingBuffer *m_pBuffer;
    std::unique_ptr<MemRingBuffer> m_pBuffer;
    map<sal_Int32,sal_Int32,less< sal_Int32 > > m_mapMarks;
    sal_Int32 m_nCurrentPos;
    sal_Int32 m_nCurrentMark;
@@ -465,14 +464,7 @@
    , m_nCurrentPos(0)
    , m_nCurrentMark(0)
{
    m_pBuffer = new MemRingBuffer;
}

OMarkableInputStream::~OMarkableInputStream()
{
    if( m_pBuffer ) {
        delete m_pBuffer;
    }
    m_pBuffer.reset( new MemRingBuffer );
}


@@ -615,8 +607,7 @@
        setPredecessor( Reference< XConnectable > () );
        setSuccessor( Reference< XConnectable >() );

        delete m_pBuffer;
        m_pBuffer = nullptr;
        m_pBuffer.reset();
        m_nCurrentPos = 0;
        m_nCurrentMark = 0;
    }
diff --git a/lotuswordpro/source/filter/lwpcharborderoverride.cxx b/lotuswordpro/source/filter/lwpcharborderoverride.cxx
index d7cb9bc..e8dabf5 100644
--- a/lotuswordpro/source/filter/lwpcharborderoverride.cxx
+++ b/lotuswordpro/source/filter/lwpcharborderoverride.cxx
@@ -88,14 +88,8 @@

LwpCharacterBorderOverride::~LwpCharacterBorderOverride()
{
    if (m_pBorderStuff)
    {
        delete m_pBorderStuff;
    }
    if (m_pMargins)
    {
        delete m_pMargins;
    }
    delete m_pBorderStuff;
    delete m_pMargins;
}

LwpCharacterBorderOverride* LwpCharacterBorderOverride::clone() const
diff --git a/lotuswordpro/source/filter/lwpdlvlist.cxx b/lotuswordpro/source/filter/lwpdlvlist.cxx
index 22781f1..2e2ea58 100644
--- a/lotuswordpro/source/filter/lwpdlvlist.cxx
+++ b/lotuswordpro/source/filter/lwpdlvlist.cxx
@@ -142,7 +142,7 @@
        m_bHasProperties = pObjStrm->QuickReaduInt8() != 0;
        if (m_bHasProperties)
        {
            m_pPropList = new LwpPropList;
            m_pPropList.reset( new LwpPropList );
            m_pPropList->Read(pObjStrm);
        }
    }
@@ -152,10 +152,6 @@
 **/
LwpDLNFPVList::~LwpDLNFPVList()
{
    if(m_pPropList)
    {
        delete m_pPropList;
    }
}

/**
diff --git a/lotuswordpro/source/filter/lwpdlvlist.hxx b/lotuswordpro/source/filter/lwpdlvlist.hxx
index bf9063c..54a5b5d2 100644
--- a/lotuswordpro/source/filter/lwpdlvlist.hxx
+++ b/lotuswordpro/source/filter/lwpdlvlist.hxx
@@ -63,6 +63,7 @@

#include "lwpatomholder.hxx"
#include "lwpobj.hxx"
#include <memory>

/**
 * @brief   Double Linked Virtual List
@@ -119,12 +120,12 @@
    virtual ~LwpDLNFPVList() override;
protected:
    bool m_bHasProperties;
    LwpPropList* m_pPropList;
    std::unique_ptr<LwpPropList> m_pPropList;
protected:
    void Read() override;
    void ReadPropertyList(LwpObjectStream* pObjStrm);
public:
    LwpPropList* GetPropList() { return m_pPropList; }
    LwpPropList* GetPropList() { return m_pPropList.get(); }
};

/**
diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index 65eb227..9455c6b 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -81,14 +81,8 @@

LwpDocument::~LwpDocument()
{
    if(m_pLnOpts)
    {
        delete m_pLnOpts;
    }
    if(m_pOwnedFoundry)
    {
        delete m_pOwnedFoundry;
    }
    delete m_pLnOpts;
    delete m_pOwnedFoundry;
}
/**
 * @descr   Read VO_Document from object stream
diff --git a/lotuswordpro/source/filter/lwpfont.cxx b/lotuswordpro/source/filter/lwpfont.cxx
index 9877207..8b430866 100644
--- a/lotuswordpro/source/filter/lwpfont.cxx
+++ b/lotuswordpro/source/filter/lwpfont.cxx
@@ -415,7 +415,7 @@
void LwpFontAttrManager::Read(LwpObjectStream *pStrm)
{
    m_nCount = pStrm->QuickReaduInt16();
    m_pFontAttrs = new LwpFontAttrEntry[m_nCount];
    m_pFontAttrs.reset( new LwpFontAttrEntry[m_nCount] );

    for(sal_uInt16 i=0; i<m_nCount; i++)
    {
@@ -435,8 +435,6 @@

LwpFontAttrManager::~LwpFontAttrManager()
{
    if(m_pFontAttrs)
        delete []m_pFontAttrs;
}

void LwpFontManager::Read(LwpObjectStream *pStrm)
diff --git a/lotuswordpro/source/filter/lwpfont.hxx b/lotuswordpro/source/filter/lwpfont.hxx
index b0297fb..1f6987fd 100644
--- a/lotuswordpro/source/filter/lwpfont.hxx
+++ b/lotuswordpro/source/filter/lwpfont.hxx
@@ -72,6 +72,7 @@
#include "lwpobj.hxx"
#include "xfilter/xffont.hxx"
#include "xfilter/xftextstyle.hxx"
#include <memory>

class LwpFontTableEntry
{
@@ -253,7 +254,7 @@
    void Override(sal_uInt16 index, rtl::Reference<XFFont> const & pFont);
private:
    sal_uInt16 m_nCount;
    LwpFontAttrEntry* m_pFontAttrs;
    std::unique_ptr<LwpFontAttrEntry[]> m_pFontAttrs;
};

class LwpFontManager
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
index 64f855c..19df22f 100644
--- a/lotuswordpro/source/filter/lwpgrfobj.cxx
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -199,12 +199,8 @@
        m_WatermarkName = m_pObjStrm->QuickReadStringPtr();
    }

    if (pServerContext != nullptr)
        delete[] pServerContext;

    if (pFilterContext != nullptr)
        delete[] pFilterContext;

    delete[] pServerContext;
    delete[] pFilterContext;
}

void LwpGraphicObject::XFConvert (XFContentContainer* pCont)
diff --git a/lotuswordpro/source/filter/lwpoverride.cxx b/lotuswordpro/source/filter/lwpoverride.cxx
index 5856a4c..f943bf7 100644
--- a/lotuswordpro/source/filter/lwpoverride.cxx
+++ b/lotuswordpro/source/filter/lwpoverride.cxx
@@ -359,22 +359,10 @@

LwpSpacingOverride::~LwpSpacingOverride()
{
    if (m_pSpacing)
    {
        delete m_pSpacing;
    }
    if (m_pAboveLineSpacing)
    {
        delete m_pAboveLineSpacing;
    }
    if (m_pParaSpacingAbove)
    {
        delete m_pParaSpacingAbove;
    }
    if (m_pParaSpacingBelow)
    {
        delete m_pParaSpacingBelow;
    }
    delete m_pSpacing;
    delete m_pAboveLineSpacing;
    delete m_pParaSpacingAbove;
    delete m_pParaSpacingBelow;
}

LwpSpacingOverride::LwpSpacingOverride(LwpSpacingOverride const& rOther)
@@ -454,19 +442,13 @@

LwpAmikakeOverride::~LwpAmikakeOverride()
{
    if (m_pBackgroundStuff)
    {
        delete m_pBackgroundStuff;
    }
}

LwpAmikakeOverride::LwpAmikakeOverride(LwpAmikakeOverride const& rOther)
    : LwpOverride(rOther)
    , m_pBackgroundStuff(nullptr)
    , m_pBackgroundStuff(::clone(rOther.m_pBackgroundStuff.get()))
    , m_nType(rOther.m_nType)
{
    std::unique_ptr<LwpBackgroundStuff> pBackgroundStuff(::clone(rOther.m_pBackgroundStuff));
    m_pBackgroundStuff = pBackgroundStuff.release();
}

LwpAmikakeOverride* LwpAmikakeOverride::clone() const
diff --git a/lotuswordpro/source/filter/lwpoverride.hxx b/lotuswordpro/source/filter/lwpoverride.hxx
index c88ed65..935fd0f 100644
--- a/lotuswordpro/source/filter/lwpoverride.hxx
+++ b/lotuswordpro/source/filter/lwpoverride.hxx
@@ -63,6 +63,7 @@

#include "lwpobjid.hxx"
#include "lwptools.hxx"
#include <memory>

class LwpObjectStream;

@@ -493,7 +494,7 @@
    LwpAmikakeOverride& operator=(LwpAmikakeOverride const& rOther) = delete;

private:
    LwpBackgroundStuff* m_pBackgroundStuff;
    std::unique_ptr<LwpBackgroundStuff> m_pBackgroundStuff;
    sal_uInt16      m_nType;

};
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index 10acd0a..eabeb99 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -134,10 +134,7 @@
        delete m_pBullOver;
        m_pBullOver = nullptr;
    }
    if(m_pIndentOverride)
    {
        delete m_pIndentOverride;
    }
    delete m_pIndentOverride;

    LwpParaProperty* pNextProp;
    while(m_pProps)
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index f251049..5b63e64 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -87,15 +87,11 @@
LwpSuperTableLayout::LwpSuperTableLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    : LwpPlacableLayout(objHdr, pStrm)
{
    m_pFrame = new LwpFrame(this);
    m_pFrame.reset(new LwpFrame(this) );
}

LwpSuperTableLayout::~LwpSuperTableLayout()
{
    if(m_pFrame)
    {
        delete m_pFrame;
    }
}
/**
 * @short    Read super table layout record
diff --git a/lotuswordpro/source/filter/lwptablelayout.hxx b/lotuswordpro/source/filter/lwptablelayout.hxx
index 11ffd63..7237df9 100644
--- a/lotuswordpro/source/filter/lwptablelayout.hxx
+++ b/lotuswordpro/source/filter/lwptablelayout.hxx
@@ -61,9 +61,11 @@
#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX
#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX

#include "lwplayout.hxx"

#include <vector>
#include <map>
#include "lwplayout.hxx"
#include <memory>

class XFTableStyle;
class XFTable;
@@ -181,7 +183,7 @@
    LwpTableLayout* GetTableLayout();
    bool IsSizeRightToContent();
    bool IsJustifiable();
    LwpFrame* m_pFrame;
    std::unique_ptr<LwpFrame> m_pFrame;
};

/**
diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index ced5726..7478558 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -702,8 +702,7 @@

TypeWriter::~TypeWriter()
{
    if (m_superTypeNames)
        delete[] m_superTypeNames;
    delete[] m_superTypeNames;

    if (m_fieldCount)
        delete[] m_fields;
@@ -714,8 +713,7 @@
    if (m_referenceCount)
        delete[] m_references;

    if (m_pUik)
        delete m_pUik;
    delete m_pUik;
}

void TypeWriter::setSuperType(sal_uInt16 index, OString const & name)
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index c46a164..af44e96 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -234,7 +234,8 @@
private:
    ScDPSource*         pSource;
    long                nDimCount;
    rtl::Reference<ScDPDimension>* ppDims;
    std::unique_ptr<rtl::Reference<ScDPDimension>[]>
                        ppDims;

public:
                            ScDPDimensions( ScDPSource* pSrc );
@@ -354,7 +355,8 @@
    //  date columns have 3 hierarchies (flat/quarter/week), other columns only one
    // #i52547# don't offer the incomplete date hierarchy implementation
    static const long   nHierCount = 1;
    rtl::Reference<ScDPHierarchy>* ppHiers;
    std::unique_ptr<rtl::Reference<ScDPHierarchy>[]>
                        ppHiers;

public:
                            ScDPHierarchies( ScDPSource* pSrc, long nD );
@@ -418,7 +420,8 @@
    long            nDim;
    long            nHier;
    long            nLevCount;
    rtl::Reference<ScDPLevel>* ppLevs;
    std::unique_ptr<rtl::Reference<ScDPLevel>[]>
                    ppLevs;

public:
                            ScDPLevels( ScDPSource* pSrc, long nD, long nH );
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 3537b46..38c21bd 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -1198,11 +1198,6 @@
ScDPDimensions::~ScDPDimensions()
{
    //TODO: release pSource

    if (ppDims)
    {
        delete[] ppDims;
    }
}

void ScDPDimensions::CountChanged()
@@ -1220,8 +1215,7 @@
        for (i=nCopy; i<nNewCount; i++)     // clear additional pointers
            ppNew[i] = nullptr;

        delete[] ppDims;
        ppDims = ppNew;
        ppDims.reset( ppNew );
    }
    nDimCount = nNewCount;
}
@@ -1288,7 +1282,7 @@
    {
        if ( !ppDims )
        {
            const_cast<ScDPDimensions*>(this)->ppDims = new rtl::Reference<ScDPDimension>[nDimCount];
            const_cast<ScDPDimensions*>(this)->ppDims.reset(new rtl::Reference<ScDPDimension>[nDimCount] );
            for (long i=0; i<nDimCount; i++)
                ppDims[i] = nullptr;
        }
@@ -1656,11 +1650,6 @@
ScDPHierarchies::~ScDPHierarchies()
{
    //TODO: release pSource

    if (ppHiers)
    {
        delete[] ppHiers;
    }
}

// very simple XNameAccess implementation using getCount/getByIndex
@@ -1725,7 +1714,7 @@
    {
        if ( !ppHiers )
        {
            const_cast<ScDPHierarchies*>(this)->ppHiers = new rtl::Reference<ScDPHierarchy>[nHierCount];
            const_cast<ScDPHierarchies*>(this)->ppHiers.reset( new rtl::Reference<ScDPHierarchy>[nHierCount] );
            for (long i=0; i<nHierCount; i++)
                ppHiers[i] = nullptr;
        }
@@ -1823,11 +1812,6 @@
ScDPLevels::~ScDPLevels()
{
    //TODO: release pSource

    if (ppLevs)
    {
        delete[] ppLevs;
    }
}

// very simple XNameAccess implementation using getCount/getByIndex
@@ -1889,7 +1873,7 @@
    {
        if ( !ppLevs )
        {
            const_cast<ScDPLevels*>(this)->ppLevs = new rtl::Reference<ScDPLevel>[nLevCount];
            const_cast<ScDPLevels*>(this)->ppLevs.reset(new rtl::Reference<ScDPLevel>[nLevCount] );
            for (long i=0; i<nLevCount; i++)
                ppLevs[i] = nullptr;
        }
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index d46891f..cb9421e 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -4389,7 +4389,7 @@
            pReject->SetState( SC_CAS_ACCEPTED );
            Append( pReject );
        }
        else if ( pReject )
        else
            delete pReject;
    }
    else
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index b367101..fd501a4 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -1204,8 +1204,7 @@
        if ((pAddress && pData->pRelationCell && (*pAddress != *(pData->pRelationCell))) ||
            (!pAddress && pData->pRelationCell) || (pAddress && !pData->pRelationCell))
        {
            if (pData->pRelationCell)
                delete pData->pRelationCell;
            delete pData->pRelationCell;
            pData->pRelationCell = pAddress;
            if (pData->pAccShape.is())
                pData->pAccShape->SetRelationSet(GetRelationSet(pData));
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
index 5b6f8df..7e80fd9 100644
--- a/sc/source/ui/Accessibility/AccessibleText.cxx
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -672,10 +672,8 @@
{
    if (pEditEngine)
        pEditEngine->SetNotifyHdl(Link<EENotify&,void>());
    if (mpViewForwarder)
        delete mpViewForwarder;
    if (mpEditViewForwarder)
        delete mpEditViewForwarder;
    delete mpViewForwarder;
    delete mpEditViewForwarder;
}

void ScAccessibleCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
@@ -897,12 +895,9 @@
    // If the object is cloned, do NOT set notify hdl.
    if (mpEditEngine && !mbIsCloned)
        mpEditEngine->SetNotifyHdl(Link<EENotify&,void>());
    if (mpViewForwarder)
        delete mpViewForwarder;
    if (mpEditViewForwarder)
        delete mpEditViewForwarder;
    if (mpForwarder)
        delete mpForwarder;
    delete mpViewForwarder;
    delete mpEditViewForwarder;
    delete mpForwarder;
}

void ScAccessibleEditObjectTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
@@ -1159,8 +1154,7 @@
{
    if (pEditEngine)
        pEditEngine->SetNotifyHdl(Link<EENotify&,void>());
    if (mpViewForwarder)
        delete mpViewForwarder;
    delete mpViewForwarder;
}

void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
@@ -1232,8 +1226,7 @@
{
    if (pEditEngine)
        pEditEngine->SetNotifyHdl(Link<EENotify&,void>());
    if (mpViewForwarder)
        delete mpViewForwarder;
    delete mpViewForwarder;
}

void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index 11fdce3..b3b0068 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -538,7 +538,7 @@
{
    if ( aRef.is() )
        aRef->DoClose();
    else if ( pMedium )
    else
        delete pMedium;
}

diff --git a/scripting/source/provider/BrowseNodeFactoryImpl.cxx b/scripting/source/provider/BrowseNodeFactoryImpl.cxx
index 773c210..daaab02 100644
--- a/scripting/source/provider/BrowseNodeFactoryImpl.cxx
+++ b/scripting/source/provider/BrowseNodeFactoryImpl.cxx
@@ -44,6 +44,8 @@

#include <vector>
#include <algorithm>
#include <memory>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::script;
@@ -165,7 +167,7 @@
    public ::cppu::WeakImplHelper< browse::XBrowseNode >
{
private:
    BrowseNodeAggregatorHash* m_hBNA;
    std::unique_ptr<BrowseNodeAggregatorHash> m_hBNA;
    vString m_vStr;
    OUString m_sNodeName;
    Reference< browse::XBrowseNode > m_origNode;
@@ -179,18 +181,9 @@
        m_origNode.set( node );
    }

    virtual ~LocationBrowseNode() override
    {
        if (m_hBNA)
        {
            delete m_hBNA;
        }
    }


    // XBrowseNode


    virtual OUString SAL_CALL getName() override
    {
        return m_sNodeName;
@@ -231,7 +224,7 @@

    void loadChildNodes()
    {
        m_hBNA = new BrowseNodeAggregatorHash;
        m_hBNA.reset( new BrowseNodeAggregatorHash );

        Sequence< Reference< browse::XBrowseNode > > langNodes =
            m_origNode->getChildNodes();
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index 0b4baed..1e26f27 100644
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -80,11 +80,6 @@

MasterScriptProvider::~MasterScriptProvider()
{
    if ( m_pPCache )
    {
        delete m_pPCache;
    }
    m_pPCache = nullptr;
}


@@ -362,15 +357,15 @@

            if ( !m_bIsPkgMSP )
            {
                m_pPCache = new ProviderCache( m_xContext, m_sAargs );
                m_pPCache.reset( new ProviderCache( m_xContext, m_sAargs ) );
            }
            else
            {
                m_pPCache = new ProviderCache( m_xContext, m_sAargs, blacklist );
                m_pPCache.reset( new ProviderCache( m_xContext, m_sAargs, blacklist ) );
            }
        }
    }
    return m_pPCache;
    return m_pPCache.get();
}


diff --git a/scripting/source/provider/MasterScriptProvider.hxx b/scripting/source/provider/MasterScriptProvider.hxx
index a776425..9864472 100644
--- a/scripting/source/provider/MasterScriptProvider.hxx
+++ b/scripting/source/provider/MasterScriptProvider.hxx
@@ -35,6 +35,7 @@
#include <com/sun/star/script/browse/XBrowseNode.hpp>

#include "ProviderCache.hxx"
#include <memory>

namespace func_provider
{
@@ -120,7 +121,7 @@
    bool m_bInitialised;
    bool m_bIsPkgMSP;
    css::uno::Reference< css::script::provider::XScriptProvider > m_xMSPPkg;
    ProviderCache* m_pPCache;
    std::unique_ptr<ProviderCache> m_pPCache;
    osl::Mutex m_mutex;
    OUString m_sCtxString;
};
diff --git a/sd/source/filter/eppt/pptx-grouptable.cxx b/sd/source/filter/eppt/pptx-grouptable.cxx
index 2e09222..712de6a 100644
--- a/sd/source/filter/eppt/pptx-grouptable.cxx
+++ b/sd/source/filter/eppt/pptx-grouptable.cxx
@@ -45,8 +45,7 @@
        GroupEntry** pTemp = new GroupEntry*[ nEntrys ];
        for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; i++ )
            pTemp[ i ] = mpGroupEntry[ i ];
        if ( mpGroupEntry )
            delete[] mpGroupEntry;
        delete[] mpGroupEntry;
        mpGroupEntry = pTemp;
    }
}
diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx
index 359b5ad..edd6d0f 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx
@@ -591,8 +591,7 @@
    for (size_t nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++)
    {
        UserData* pData = GetUserData(nIndex);
        if (pData != nullptr)
            delete pData;
        delete pData;
    }
    PreviewValueSet::Clear();
}
diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx
index 0126a1d..88c66acb4 100644
--- a/sd/source/ui/view/OutlinerIterator.cxx
+++ b/sd/source/ui/view/OutlinerIterator.cxx
@@ -684,8 +684,7 @@
    IteratorImplBase::Reverse ();

    // Create reversed object list iterator.
    if (mpObjectIterator != nullptr)
        delete mpObjectIterator;
    delete mpObjectIterator;
    if (mpPage != nullptr)
        mpObjectIterator = new SdrObjListIter(*mpPage, SdrIterMode::DeepNoGroups, ! mbDirectionIsForward);
    else
diff --git a/sd/source/ui/view/drviewsc.cxx b/sd/source/ui/view/drviewsc.cxx
index 9f245cc..5bbf7ff 100644
--- a/sd/source/ui/view/drviewsc.cxx
+++ b/sd/source/ui/view/drviewsc.cxx
@@ -76,10 +76,7 @@
        SvxIMapDlgChildWindow::UpdateIMapDlg( aGraphic, pIMap, pTargetList, pObj );

        // We can delete the target list
        if ( pTargetList )
        {
            delete pTargetList;
        }
        delete pTargetList;
    }
}

diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index 61dd557..75e6145 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -1683,8 +1683,7 @@

void ViewShellObjectBarFactory::ReleaseShell (SfxShell* pShell)
{
    if (pShell != nullptr)
        delete pShell;
    delete pShell;
}

} // end of anonymous namespace
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index 77a7e4d..b9bcabb 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -419,8 +419,7 @@
void SfxRequest::SetReturnValue(const SfxPoolItem &rItem)
{
    DBG_ASSERT(!pImpl->pRetVal, "Set Return value multiple times?");
    if(pImpl->pRetVal)
        delete pImpl->pRetVal;
    delete pImpl->pRetVal;
    pImpl->pRetVal = rItem.Clone();
}

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 8f8059e..b86dba5 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -3470,8 +3470,7 @@
void SfxMedium::CreateTempFileNoCopy()
{
    // this call always replaces the existing temporary file
    if ( pImpl->pTempFile )
        delete pImpl->pTempFile;
    delete pImpl->pTempFile;

    pImpl->pTempFile = new ::utl::TempFile();
    pImpl->pTempFile->EnableKillingFile();
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index 15cb099..de54631 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -296,20 +296,9 @@
                maChildren.pop_back();
            }

            if(mpId)
            {
                delete mpId;
            }

            if(mpClass)
            {
                delete mpClass;
            }

            if(mpLocalCssStyle)
            {
                delete mpLocalCssStyle;
            }
            delete mpId;
            delete mpClass;
            delete mpLocalCssStyle;
        }

        void SvgNode::readLocalCssStyle(const OUString& aContent)
diff --git a/svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx b/svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx
index 75ecbf6..46f6e4d 100644
--- a/svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx
+++ b/svx/inc/sdr/contact/viewobjectcontactofgraphic.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SVX_INC_SDR_CONTACT_VIEWOBJECTCONTACTOFGRAPHIC_HXX

#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
#include <memory>

class SdrGrafObj;

@@ -40,7 +41,7 @@

            // Member which takes care for the asynch loading events which may be necessary
            // for asynch graphics loading.
            sdr::event::AsynchGraphicLoadingEvent*      mpAsynchLoadEvent;
            std::unique_ptr<sdr::event::AsynchGraphicLoadingEvent>  mpAsynchLoadEvent;

            // async graphics loading helpers. Only to be used internally or from the
            // event helper class (in .cxx file)
diff --git a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
index 3b42c38..16c15b4 100644
--- a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
@@ -112,7 +112,7 @@
                            // Trigger asynchronious SwapIn.
                            sdr::event::TimerEventHandler& rEventHandler = rObjectContact.GetEventHandler();

                            mpAsynchLoadEvent = new sdr::event::AsynchGraphicLoadingEvent(rEventHandler, *this);
                            mpAsynchLoadEvent.reset( new sdr::event::AsynchGraphicLoadingEvent(rEventHandler, *this) );
                        }
                    }
                    else
@@ -142,7 +142,7 @@
                {
                    // just delete it, this will remove it from the EventHandler and
                    // will trigger forgetAsynchGraphicLoadingEvent from the destructor
                    delete mpAsynchLoadEvent;
                    mpAsynchLoadEvent.reset();

                    // Invalidate paint areas.
                    // [1] If a calc document with graphics is loaded then OnLoad will
@@ -222,7 +222,7 @@

            if(mpAsynchLoadEvent)
            {
                OSL_ENSURE(!pEvent || mpAsynchLoadEvent == pEvent,
                OSL_ENSURE(!pEvent || mpAsynchLoadEvent.get() == pEvent,
                    "ViewObjectContactOfGraphic::forgetAsynchGraphicLoadingEvent: Forced to forget another event then I have scheduled (?)");

                // forget event
@@ -302,13 +302,6 @@

        ViewObjectContactOfGraphic::~ViewObjectContactOfGraphic()
        {
            // evtl. delete the asynch loading event
            if(mpAsynchLoadEvent)
            {
                // just delete it, this will remove it from the EventHandler and
                // will trigger forgetAsynchGraphicLoadingEvent from the destructor
                delete mpAsynchLoadEvent;
            }
        }
    } // end of namespace contact
} // end of namespace sdr
diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx
index 8cc07bd..b2d840c 100644
--- a/svx/source/sdr/properties/textproperties.cxx
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -337,10 +337,7 @@
                                }
                            }

                            if(pTempSet)
                            {
                                delete pTempSet;
                            }
                            delete pTempSet;
                        }

                        OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount);
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index ff71c07d..2657375 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -991,10 +991,7 @@
            pGivenOutlinerView = nullptr;
        }
    }
    if( pTextEditOutliner!=nullptr )
    {
        delete pTextEditOutliner;
    }
    delete pTextEditOutliner;

    pTextEditOutliner=nullptr;
    pTextEditOutlinerView=nullptr;
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 0c3dad0c..d4f5ef2 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -52,6 +52,7 @@
#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <svx/sdr/attribute/sdrformtextattribute.hxx>
#include <memory>

using namespace sdr;

@@ -501,12 +502,12 @@
    SdrPathObj&                 mrSdrPathObject;
    XPolyPolygon                aPathPolygon;
    SdrObjKind                  meObjectKind;
    ImpSdrPathDragData*         mpSdrPathDragData;
    std::unique_ptr<ImpSdrPathDragData>
                                mpSdrPathDragData;
    bool                        mbCreating;

public:
    explicit ImpPathForDragAndCreate(SdrPathObj& rSdrPathObject);
    ~ImpPathForDragAndCreate();

    // drag stuff
    bool beginPathDrag( SdrDragStat& rDrag )  const;
@@ -544,14 +545,6 @@
{
}

ImpPathForDragAndCreate::~ImpPathForDragAndCreate()
{
    if(mpSdrPathDragData)
    {
        delete mpSdrPathDragData;
    }
}

bool ImpPathForDragAndCreate::beginPathDrag( SdrDragStat& rDrag )  const
{
    const SdrHdl* pHdl=rDrag.GetHdl();
@@ -585,13 +578,12 @@
            bMultiPointDrag = false;
    }

    const_cast<ImpPathForDragAndCreate*>(this)->mpSdrPathDragData = new ImpSdrPathDragData(mrSdrPathObject,*pHdl,bMultiPointDrag,rDrag);
    const_cast<ImpPathForDragAndCreate*>(this)->mpSdrPathDragData.reset( new ImpSdrPathDragData(mrSdrPathObject,*pHdl,bMultiPointDrag,rDrag) );

    if(!mpSdrPathDragData || !mpSdrPathDragData->bValid)
    {
        OSL_FAIL("ImpPathForDragAndCreate::BegDrag(): ImpSdrPathDragData is invalid.");
        delete mpSdrPathDragData;
        const_cast<ImpPathForDragAndCreate*>(this)->mpSdrPathDragData = nullptr;
        const_cast<ImpPathForDragAndCreate*>(this)->mpSdrPathDragData.reset();
        return false;
    }

@@ -915,8 +907,7 @@
        }
    }

    delete mpSdrPathDragData;
    mpSdrPathDragData = nullptr;
    mpSdrPathDragData.reset();

    return true;
}
@@ -992,7 +983,7 @@
    else
    {
        // #i103058# standard for modification; model and handle needed
        ImpSdrPathDragData* pDragData = mpSdrPathDragData;
        ImpSdrPathDragData* pDragData = mpSdrPathDragData.get();

        if(!pDragData)
        {
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index a4d4c34..c099553 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -182,11 +182,7 @@
    if(pCandidate)
    {
        pCandidate = RemovePageWindow(*pCandidate);

        if(pCandidate)
        {
            delete pCandidate;
        }
        delete pCandidate;
    }
}

diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx
index 3f0f07d..559e6b9 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -46,10 +46,8 @@

TextChainFlow::~TextChainFlow()
{
    if (mpOverflChText)
        delete mpOverflChText;
    if (mpUnderflChText)
        delete mpUnderflChText;
    delete mpOverflChText;
    delete mpUnderflChText;
}

void TextChainFlow::impSetFlowOutlinerParams(SdrOutliner *, SdrOutliner *)
diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx
index ff064151..317ca98 100644
--- a/svx/source/xoutdev/xpool.cxx
+++ b/svx/source/xoutdev/xpool.cxx
@@ -179,10 +179,7 @@
    // release and delete static pool default items
    ReleaseDefaults(true);

    if(mpLocalItemInfos)
    {
        delete[] mpLocalItemInfos;
    }
    delete[] mpLocalItemInfos;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index e08b698..945104ce 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -771,9 +771,7 @@
{
    FndBox_** ppTmp = const_cast<FndBox_**>(pArr);
    delete [] ppTmp;

    if( ppItemSets )
        delete [] ppItemSets;
    delete [] ppItemSets;
}

/// All Lines of a Box need to have same number of Boxes
diff --git a/sw/source/core/text/wrong.cxx b/sw/source/core/text/wrong.cxx
index e7f4b0d..6da8afc 100644
--- a/sw/source/core/text/wrong.cxx
+++ b/sw/source/core/text/wrong.cxx
@@ -83,8 +83,7 @@
{
    for (SwWrongArea & i : maList)
    {
        if (i.mpSubList)
            delete i.mpSubList;
        delete i.mpSubList;
        i.mpSubList = nullptr;
    }
    maList.clear();
@@ -573,8 +572,7 @@
    std::vector<SwWrongArea>::iterator iLoop = i1;
    while ( iLoop != i2 )
    {
        if ( (*iLoop).mpSubList )
            delete (*iLoop).mpSubList;
        delete (*iLoop).mpSubList;
        ++iLoop;
    }

diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 5001851..f6ff3e80e 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -200,7 +200,7 @@
            rUNds.GetEndOfExtras().GetIndex() - m_pUndoNodeIndex->GetIndex());
        m_pUndoNodeIndex.reset();
    }
    else if( pText )     // the inserted text
    else     // the inserted text
        delete pText;
    delete pRedlData;
    delete pUndoText;
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 1954d30..88b6fca 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -3396,10 +3396,7 @@

    //The TOC field representation contents should be inserted into TOC section, but not after TOC section.
    //So we need update the document position when loading TOC representation and after loading TOC;
    if (m_pPosAfterTOC)
    {
        delete m_pPosAfterTOC;
    }
    delete m_pPosAfterTOC;
    m_pPosAfterTOC = new SwPaM(*m_pPaM, m_pPaM);
    (*m_pPaM).Move(fnMoveBackward);
    SwPaM aRegion(*m_pPaM, m_pPaM);
diff --git a/vcl/inc/unx/salobj.h b/vcl/inc/unx/salobj.h
index ffc738a..ba35bee 100644
--- a/vcl/inc/unx/salobj.h
+++ b/vcl/inc/unx/salobj.h
@@ -23,6 +23,7 @@
#include <salobj.hxx>
#include <vcl/sysdata.hxx>
#include <vclpluginapi.h>
#include <memory>

class SalClipRegion
{
@@ -36,7 +37,7 @@
    void        UnionClipRegion( long nX, long nY, long nWidth, long nHeight );

    XRectangle *EndSetClipRegion()  {
        return ClipRectangleList;   }
        return ClipRectangleList.get(); }
    void        ResetClipRegion()   {
        numClipRectangles = 0;      }
    int         GetRectangleCount() {
@@ -44,7 +45,8 @@

private:

    XRectangle* ClipRectangleList;
    std::unique_ptr<XRectangle[]>
                ClipRectangleList;
    int         numClipRectangles;
    int         maxClipRectangles;
};
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index 1376476..31b7d5f 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -3172,7 +3172,7 @@
    maComment   ( rAct.maComment ),
    mnValue     ( rAct.mnValue )
{
    ImplInitDynamicData( rAct.mpData, rAct.mnDataSize );
    ImplInitDynamicData( rAct.mpData.get(), rAct.mnDataSize );
}

MetaCommentAction::MetaCommentAction( const OString& rComment, sal_Int32 nValue, const sal_uInt8* pData, sal_uInt32 nDataSize ) :
@@ -3185,8 +3185,6 @@

MetaCommentAction::~MetaCommentAction()
{
    if ( mpData )
        delete[] mpData;
}

void MetaCommentAction::ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize )
@@ -3194,8 +3192,8 @@
    if ( nDataSize && pData )
    {
        mnDataSize = nDataSize;
        mpData = new sal_uInt8[ mnDataSize ];
        memcpy( mpData, pData, mnDataSize );
        mpData.reset( new sal_uInt8[ mnDataSize ] );
        memcpy( mpData.get(), pData, mnDataSize );
    }
    else
    {
@@ -3229,7 +3227,7 @@
            bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN");
            if ( bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN" )
            {
                SvMemoryStream  aMemStm( static_cast<void*>(mpData), mnDataSize, StreamMode::READ );
                SvMemoryStream  aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ );
                SvMemoryStream  aDest;
                if ( bPathStroke )
                {
@@ -3265,7 +3263,7 @@

                    WriteSvtGraphicFill( aDest, aFill );
                }
                delete[] mpData;
                mpData.reset();
                ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() );
            }
        }
@@ -3285,7 +3283,7 @@
            bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN");
            if ( bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN" )
            {
                SvMemoryStream  aMemStm( static_cast<void*>(mpData), mnDataSize, StreamMode::READ );
                SvMemoryStream  aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ );
                SvMemoryStream  aDest;
                if ( bPathStroke )
                {
@@ -3304,10 +3302,10 @@
                    aFill.setPath( aPath );
                    WriteSvtGraphicFill( aDest, aFill );
                }
                delete[] mpData;
                mpData.reset();
                ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() );
            } else if( maComment == "EMF_PLUS_HEADER_INFO" ){
                SvMemoryStream  aMemStm( static_cast<void*>(mpData), mnDataSize, StreamMode::READ );
                SvMemoryStream  aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ );
                SvMemoryStream  aDest;

                sal_Int32 nLeft(0), nRight(0), nTop(0), nBottom(0);
@@ -3345,7 +3343,7 @@
    rOStm.WriteInt32( mnValue ).WriteUInt32( mnDataSize );

    if ( mnDataSize )
        rOStm.WriteBytes( mpData, mnDataSize );
        rOStm.WriteBytes( mpData.get(), mnDataSize );
}

void MetaCommentAction::Read( SvStream& rIStm, ImplMetaReadData* )
@@ -3363,15 +3361,13 @@

    SAL_INFO("vcl.gdi", "MetaCommentAction::Read " << maComment);

    delete[] mpData;
    mpData.reset();

    if( mnDataSize )
    {
        mpData = new sal_uInt8[ mnDataSize ];
        rIStm.ReadBytes(mpData, mnDataSize);
        mpData.reset(new sal_uInt8[ mnDataSize ]);
        rIStm.ReadBytes(mpData.get(), mnDataSize);
    }
    else
        mpData = nullptr;
}

MetaLayoutModeAction::MetaLayoutModeAction() :
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index b7d1a93..79bdc4a 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -919,8 +919,7 @@
        gxWatchdog.clear();
    }

    if (gpWatchdogExit)
        delete gpWatchdogExit;
    delete gpWatchdogExit;
    gpWatchdogExit = nullptr;
}

diff --git a/vcl/source/window/accel.cxx b/vcl/source/window/accel.cxx
index b0c7f91..28c9844 100644
--- a/vcl/source/window/accel.cxx
+++ b/vcl/source/window/accel.cxx
@@ -162,9 +162,7 @@
{
    // delete accelerator-entries using the id-table
    for (ImplAccelEntry* pEntry : mpData->maIdList) {
        if ( pEntry->mpAutoAccel ) {
            delete pEntry->mpAutoAccel;
        }
        delete pEntry->mpAutoAccel;
        delete pEntry;
    }
    mpData->maIdList.clear();
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 1744dc6..1ea8598 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -4136,8 +4136,7 @@

void X11SalFrame::BeginSetClipRegion( sal_uLong nRects )
{
    if( m_pClipRectangles )
        delete [] m_pClipRectangles;
    delete [] m_pClipRectangles;
    if( nRects )
        m_pClipRectangles = new XRectangle[nRects];
    else
diff --git a/vcl/unx/generic/window/salobj.cxx b/vcl/unx/generic/window/salobj.cxx
index 186af85..e3ec1b4 100644
--- a/vcl/unx/generic/window/salobj.cxx
+++ b/vcl/unx/generic/window/salobj.cxx
@@ -187,17 +187,12 @@

SalClipRegion::~SalClipRegion()
{
    if ( ClipRectangleList )
        delete [] ClipRectangleList;
}

void
SalClipRegion::BeginSetClipRegion( sal_uLong nRects )
{
    if (ClipRectangleList)
        delete [] ClipRectangleList;

    ClipRectangleList = new XRectangle[nRects];
    ClipRectangleList.reset( new XRectangle[nRects] );
    numClipRectangles = 0;
    maxClipRectangles = nRects;
}
@@ -207,12 +202,12 @@
{
    if ( nWidth && nHeight && (numClipRectangles < maxClipRectangles) )
    {
        XRectangle *aRect = ClipRectangleList + numClipRectangles;
        XRectangle& aRect = ClipRectangleList[numClipRectangles];

        aRect->x     = (short) nX;
        aRect->y     = (short) nY;
        aRect->width = (unsigned short) nWidth;
        aRect->height= (unsigned short) nHeight;
        aRect.x     = (short) nX;
        aRect.y     = (short) nY;
        aRect.width = (unsigned short) nWidth;
        aRect.height= (unsigned short) nHeight;

        numClipRectangles++;
    }
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx
index 5b3f8ae1..18c1666 100644
--- a/xmlscript/source/xml_helper/xml_impctx.cxx
+++ b/xmlscript/source/xml_helper/xml_impctx.cxx
@@ -85,8 +85,8 @@
{
    Mutex * m_pMutex;
public:
    explicit MGuard( Mutex * pMutex )
        : m_pMutex( pMutex )
    explicit MGuard( std::unique_ptr<Mutex> const & pMutex )
        : m_pMutex( pMutex.get() )
        { if (m_pMutex) m_pMutex->acquire(); }
    ~MGuard() throw ()
        { if (m_pMutex) m_pMutex->release(); }
@@ -118,7 +118,7 @@
    std::vector< ElementEntry * > m_elements;
    sal_Int32 m_nSkipElements;

    Mutex * m_pMutex;
    std::unique_ptr<Mutex> m_pMutex;

    inline Reference< xml::input::XElement > getCurrentElement() const;

@@ -136,7 +136,6 @@
    DocumentHandlerImpl(
        Reference< xml::input::XRoot > const & xRoot,
        bool bSingleThreadedUse );
    virtual ~DocumentHandlerImpl() throw () override;

    // XServiceInfo
    virtual OUString SAL_CALL getImplementationName() override;
@@ -187,18 +186,7 @@
    m_elements.reserve( 10 );

    if (! bSingleThreadedUse)
        m_pMutex = new Mutex();
}

DocumentHandlerImpl::~DocumentHandlerImpl() throw ()
{
    if (m_pMutex != nullptr)
    {
        delete m_pMutex;
#if OSL_DEBUG_LEVEL == 0
        m_pMutex = nullptr;
#endif
    }
        m_pMutex.reset(new Mutex);
}

inline Reference< xml::input::XElement >